/**
 * Project Name:九色鹿
 * File Name:QueryTrackService.java
 * Package Name:com.fxp.project.express.service.impl
 * Date:2021年09月14日 15:28
 * Copyright (c) 2021, Jason.Wang All Rights Reserved.
 */
package com.fxp.project.express.service.impl;

import com.fxp.project.express.entity.request.QueryTrackParam;
import com.fxp.project.express.entity.response.QueryTrackResp;
import com.fxp.project.express.provider.KuaiDiProvider;
import lombok.Data;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

/**
 * ClassName:QueryTrackService<br/>
 * Function: 运单的实时查询<br/>
 * Date:2021年09月14日 15:28<br/>
 *
 * @author Jason.Wang
 * @version 1.0.0.0
 * @see
 * @since JDK 8
 */
@Data
@Log4j2
@Component
public class QueryTrackService {

    private final KuaiDiProvider provider;

    private volatile static QueryTrackService instance;

    /**
     * initInstance: 获取单例的实体对象<br/>
     *
     * @param provider
     * @author Jason.Wang
     * @date 2021/9/13 17:45
     */
    public static void initInstance(KuaiDiProvider provider) {
        if (instance == null) {
            synchronized (QueryTrackService.class) {
                if (instance == null) {
                    instance = new QueryTrackService(provider);
                }
            }
        }
    }

    /**
     * getInstance: 获取单例对象方法<br/>
     *
     * @return
     * @author Jason.Wang
     * @date 2021/9/13 17:46
     */
    public static QueryTrackService getInstance() {
        return instance;
    }

    /**
     * QueryTrackService: 私有构建方法<br/>
     *
     * @param provider
     * @author Jason.Wang
     * @date 2021/9/13 17:46
     */
    private QueryTrackService(KuaiDiProvider provider) {
        this.provider = provider;
    }

    /**
     * queryTrack: 查询快递单的实时信息<br/>
     *
     * @param queryTrackParam
     * @return
     * @throws Exception
     * @author Jason.Wang
     * @date 2021/9/14 15:34
     */
    public QueryTrackResp queryTrack(QueryTrackParam queryTrackParam) throws Exception {
        return provider.queryTrack(queryTrackParam);
    }
}